import type { SogouElements } from '../../../../../../../../types/constants/personalization/sogou'
import { ThemeVarService } from '../../../../../../../../lib/abstract/style/theme_var/service'
import {
  generateHideSelector,
  PAGE_ELEMENTS,
  SUPPORTED_PLATFORMS,
} from '../../../../../../../../types/constants'

export class SogouIndexWeixinPage {
  elements: SogouElements = PAGE_ELEMENTS[SUPPORTED_PLATFORMS.SO_GOU]
  private static instance: SogouIndexWeixinPage
  protected readonly themeVarService: ThemeVarService = ThemeVarService.getInstance()

  /**
   * 获取单例实例
   */
  public static getInstance(): SogouIndexWeixinPage {
    if (!SogouIndexWeixinPage.instance) {
      SogouIndexWeixinPage.instance = new SogouIndexWeixinPage()
    }
    return SogouIndexWeixinPage.instance
  }

  init(): void {
  }

  getMainStyles(): string {
    return `
  /* 隐藏样式 */    
  .wrapper .header:has(${generateHideSelector('.top-nav')}):has(${generateHideSelector('.user-box')}) {
    background-color: transparent !important;
  }
  .wrapper .header:has(${generateHideSelector('.user-box')}) {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
  }
  
  /* 主样式 */  
  .wrapper {
    /* 顶部菜单*/
    .header {
      background-color: var(${this.themeVarService.search.header.background}) !important;
      
      .top-nav {
        li {
          &.cur {
            span {
              color: var(${this.themeVarService.tab.textActive}) !important;
              border-bottom: 2px solid var(${this.themeVarService.tab.textActive}) !important;
            }
          }

          > a {
            color: var(${this.themeVarService.search.default.text}) !important;
            
            &:hover {
              color: var(${this.themeVarService.link.default.text}) !important;
            }
          }
        }
      }
      
      .user-box {
        #cniil_wza {
          color: var(${this.themeVarService.search.default.text}) !important;
          
          &:hover {
            color: var(${this.themeVarService.link.default.text}) !important;
          }
        }
      }
    }
    
    /* 主内容 */
    .content {
      .search-box {        
        #searchForm {
          .search-in-box {
            border: none !important;

            .suggestion {
              border-color: var(${this.themeVarService.default.border.colorNeutral}) !important;
              width: 100% !important;
              
              .suglist {
                font-size: ${this.themeVarService.search.default.fontSize} !important;
                
                > li {
                  color: var(${this.themeVarService.search.suggestions.text}) !important;
                  
                  &:hover {
                    b {
                      color: var(${this.themeVarService.link.default.text}) !important;
                    }
                  }
                  
                  &:has(> b) {
                    color: var(${this.themeVarService.em.text}) !important;
                    
                    b {
                      color: var(${this.themeVarService.search.suggestions.text}) !important;
                      font-weight: ${this.themeVarService.search.suggestions.fontWeight} !important;
                    }
                  }
                  
                  &[history] {
                    color: var(${this.themeVarService.search.history.text}) !important;
                    
                    &:hover {
                      color: var(${this.themeVarService.link.default.text}) !important;
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
    
    /* 页脚 */
    #footer {
      color: var(${this.themeVarService.search.default.text}) !important;

      span {
        color: var(${this.themeVarService.search.default.text}) !important;
      }
      
      a {
        color: var(${this.themeVarService.link.default.text}) !important;
        
        &:hover {
          color: var(${this.themeVarService.link.default.textHover}) !important;
          text-decoration: none !important;
        }
      }
    }
  }  
    `
  }
}
